import { ElMessage } from "element-plus";
import { getCurrentInstance } from "vue";

const {proxy} = getCurrentInstance();

const httpRequest = (proxy,method,url,data,callback)=>{

    proxy.$axios({
        method: method,
        url: url,
        data: data
    }).then(res=>{
        let resultBean = res.data;
        if(resultBean.code == 200){
            callback(resultBean);
        }else{
            ElMessage.error(resultBean.msg);
        }
    }).catch(error=>{
        ElMessage.error(error.message);
    })

}


export default httpRequest;


